package com.huida.app.hutoolsusage;

import cn.hutool.core.util.CharsetUtil;
import cn.hutool.core.util.HexUtil;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;

/**
 * @author wangzhuangzhuang
 * @DESC:
 * @date 2022-01-10 16:06
 */
@SpringBootTest
public class HexUtilUsageDemo {

	/**
	 * 十六进制（Hex）在数学中是一种逢16进1的进位制
	 * */
	@Test
	public void test01(){
		String str = "Hello World";
		// 编码
		String hexStr = HexUtil.encodeHexStr(str, CharsetUtil.CHARSET_UTF_8);
		System.out.println("hexStr: " + hexStr); // hexStr: 48656c6c6f20576f726c64

		// 解码
		String hex = HexUtil.decodeHexStr(hexStr);
		System.out.println("hex: " + hex); // hex: Hello World
	}


}